//
//  ServiceAPIClient.m
//  TestAFNetworking
//
//  Created by Lawrence Zhang on 13-1-15.
//  Copyright (c) 2013年 Lawrence Zhang. All rights reserved.
//

#import "ServiceAPIClient.h"
#import "AFJSONRequestOperation.h"

@implementation ServiceAPIClient

+ (ServiceAPIClient *)sharedClient
{
    static ServiceAPIClient *_sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedClient = [[ServiceAPIClient alloc] initWithBaseURL:[NSURL URLWithString:APIURL]];
    });
    return  _sharedClient;
}

- (id)initWithBaseURL:(NSURL *)url
{
    self = [super initWithBaseURL:url];
    if (!self) {
        return nil;
    }
    [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
    [self setDefaultHeader:@"Accept" value:@"application/json"];
    return self;
}

@end
